package com.heima.behavior.controller.v1;

import com.heima.behavior.service.IApBehaviorService;
import com.heima.model.behavior.dtos.CollectionBehaviorDto;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/api/v1/")
public class ApBehaviorController {

    @Resource
    private IApBehaviorService apBehaviorService;

    @PostMapping("/likes_behavior")
    public ResponseResult like(@Validated @NotNull @RequestBody LikesBehaviorDto dto) {
        return apBehaviorService.likes(dto);
    }

    @PostMapping("/read_behavior")
    public ResponseResult read(@Validated @NotNull @RequestBody ReadBehaviorDto dto) {
        return apBehaviorService.read(dto);
    }

    @PostMapping("/un_likes_behavior")
    public ResponseResult unlike(@Validated @NotNull @RequestBody UnLikesBehaviorDto dto) {
        return apBehaviorService.unlikes(dto);
    }

}
